package com.xinfu.newproject.ui.carFee.add_parking;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.xinfu.newproject.R;
import com.xinfu.newproject.adapter.park_adapter.MonthCardPayListAdapter;
import com.xinfu.newproject.base.BaseActivity;
import com.xinfu.newproject.bean.park_bean.bean.AddMonthCarBean;
import com.xinfu.newproject.bean.park_bean.bean.CheckMonthParkBean;
import com.xinfu.newproject.bean.park_bean.bean.FeeListBean;
import com.xinfu.newproject.bean.park_bean.bean.GetMonthCarListBean;
import com.xinfu.newproject.bean.park_bean.bean.GetParkingBean;
import com.xinfu.newproject.bean.park_bean.bean.PaymentsBean;
import com.xinfu.newproject.bean.paycost.bean.ComputeParkingBean;
import com.xinfu.newproject.presenter.ParkingPresenter;
import com.xinfu.newproject.view.IView;

import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.disposables.Disposable;

public class MonthParkRecordActivity extends BaseActivity implements IView.IParkingView {

    @BindView(R.id.activity_month_park_record_rv)
    RecyclerView mRecyclerView;

    private View notDataView;

    private MonthCardPayListAdapter monthCardPayListAdapter;

    private ParkingPresenter parkingPresenter = new ParkingPresenter(this);

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_month_park_record);
        ButterKnife.bind(this);
        registerBack();
        setActivityTitle("续费记录");
        initViewBind();
        initLisener();

    }

    private void initLisener() {

    }

    private void initViewBind() {
        parkingPresenter.feeList();
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        monthCardPayListAdapter = new MonthCardPayListAdapter();
        View headerView = LayoutInflater.from(this).inflate(R.layout.item_monthcard_paylist_head, null);
        monthCardPayListAdapter.addHeaderView(headerView);
        mRecyclerView.setAdapter(monthCardPayListAdapter);
        TextView tvCarParkName = (TextView) headerView.findViewById(R.id.tv_carparkname);
        TextView tvOwnername = (TextView) headerView.findViewById(R.id.tv_ownername);
        TextView tvCarNum = (TextView) headerView.findViewById(R.id.tv_carnum);
        String mCarParkName = getIntent().getStringExtra("carParkName");
        String mOwnerName = getIntent().getStringExtra("ownerName");
        String mCarNum = getIntent().getStringExtra("carNum");
        tvCarParkName.setText(mCarParkName);
        tvOwnername.setText(mOwnerName);
        tvCarNum.setText(mCarNum);

        notDataView = getLayoutInflater().inflate(R.layout.empty_view, (ViewGroup) mRecyclerView.getParent(), false);
        notDataView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                parkingPresenter.feeList();
            }
        });
    }

    @Override
    public String header() {
        return getIntent().getExtras().getString("tenantId");
    }

    @Override
    public String userId() {
        return null;
    }

    @Override
    public String parkInfoId() {
        return null;
    }

    @Override
    public String carId() {
        return getIntent().getExtras().getString("parkCarId");
    }

    @Override
    public Integer carType() {
        return null;
    }

    @Override
    public String projectId() {
        return null;
    }

    @Override
    public String exclusiveFlag() {
        return null;
    }

    @Override
    public String monthCarType() {
        return null;
    }

    @Override
    public String roomId() {
        return null;
    }

    @Override
    public String owner() {
        return null;
    }

    @Override
    public String mobile() {
        return null;
    }

    @Override
    public String images() {
        return null;
    }

    @Override
    public String remark() {
        return null;
    }

    @Override
    public Integer idType() {
        return null;
    }

    @Override
    public String filed1() {
        return null;
    }

    @Override
    public String id() {
        return null;
    }

    @Override
    public String startTime() {
        return null;
    }

    @Override
    public String orderId() {
        return null;
    }

    @Override
    public String licensePlate() {
        return null;
    }

    @Override
    public void showToast(String content) {
        monthCardPayListAdapter.setEmptyView(notDataView);
    }

    @Override
    public void closeDispose(Disposable disposable) {

    }

    @Override
    public void showProgress() {

    }

    @Override
    public void hideProgress() {

    }

    @Override
    public void getMsg(GetParkingBean getParkingBean) {

    }

    @Override
    public void getMsg(CheckMonthParkBean checkMonthParkBean) {

    }

    @Override
    public void getMsg(AddMonthCarBean addMonthCarBean) {

    }

    @Override
    public void getMsg(GetMonthCarListBean getMonthCarListBean) {

    }

    @Override
    public void getMsg(PaymentsBean paymentsBean) {

    }

    @Override
    public void getMsg(ComputeParkingBean computeParkingBean) {

    }

    @Override
    public void getMsg(FeeListBean feeListBean) {

        if (feeListBean.getResult() != null) {
            if (feeListBean.getResult().size() > 0) {
                monthCardPayListAdapter.setNewData(feeListBean.getResult());
            } else {
                monthCardPayListAdapter.setEmptyView(notDataView);
            }
        } else {
            monthCardPayListAdapter.setEmptyView(notDataView);
        }
    }
}
